import {AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig} from "axios";

export interface InterceptorHooks {
    requestInterceptor?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig;
    requestInterceptorCatch?: (error: Result<any>) => any;

    responseInterceptor?: (response: AxiosResponse) => AxiosResponse;
    responseInterceptorCatch?: (error: AxiosError<Result<any>>) => any;
}

export interface RequestConfig extends AxiosRequestConfig {
    interceptorHooks?: InterceptorHooks;
}

export interface Result<T> {
    code: number;
    data: T;
    message: string;
    success: boolean;
}
